{extend name="v1/layout/base"}
{block name="content"}
<div class="layui-row layui-col-space15">
  <div class="layui-col-md12">
      <form class="layui-card-body layui-form layui-form-pane">
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">运费模板名称：</label>
            <div class="layui-input-block">
              <input type="text" name="shipping_type_name" value="{$info.shipping_type_name}" lay-verify="required" lay-reqtext="请输入运费模板名称" placeholder="请输入运费模板名称" autocomplete="off" class="layui-input">
            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">计费规则：</label>
            <div class="layui-input-block">
              <input type="radio" name="price_type" value="1" title="每件计算" {$info['price_type']==1?'checked':''}>
              <input type="radio" name="price_type" value="2" title="整单计算" {$info['price_type']==2?'checked':''}>
            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">指定区域：</label>
            <div class="layui-input-block" id="search-select">

            </div>
          </div>
        </div>
        <div class="layui-row layui-col-space10 layui-form-item">
          <div class="layui-col-lg8">
            <label class="layui-form-label">运费：</label>
            <div class="layui-input-block">
              <input type="text" name="price" value="{$info.price}" lay-verify="required" lay-reqtext="请输入运费" placeholder="请输入运费" autocomplete="off" class="layui-input">
            </div>
          </div>
        </div>
        <!-- 底部操作按钮 -->
        <div class="layui-row">
          <div class="layui-col-xs3">&nbsp;</div>
          <div class="layui-col-xs4">
            <input type="hidden" name="act" value="edit" />
            <input type="hidden" name="store_id" value="{$info.store_id}">
            <input type="hidden" name="shipping_type_id" value="{$info.shipping_type_id}">
            <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" id="backList"><i class="layui-icon">&#xe65c;</i>返回列表</button>
            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit lay-filter="saveBtn"><i class="layui-icon">&#xe609;</i>立即更新</button>
          </div>
          <div class="layui-col-xs5">&nbsp;</div>
        </div>
        <!-- 底部操作按钮结束 -->
      </form>
  </div>
</div>
{/block}
{block name="myScript"}
<script src="__COMMON__js/xm-select.js" charset="utf-8"></script>
<script>
  getCity();
  function getCity(){
    var url = "{:url('/'.config('manage.manage_name').'/'.config('manage.version').'/System/getCity')}",
    store_id = '{$info.store_id}',
    shipping_type_id = '{$info.shipping_type_id}';
    https(url,{store_id:store_id,shipping_type_id: shipping_type_id},'post',0,'').then(res=>{
      if(res.result_code == 200){
        var demo1 = xmSelect.render({
          el: '#search-select',
          filterable: true,
          data: res.resultData,
         })
      }
    })
  }
  layui.use(['form'], function() {
    var form = layui.form,
      layer = layui.layer,
      $ = layui.$;
    //监听提交
    form.on('submit(saveBtn)', function(data) {
      var data = data.field,
          url = "{:url('/'.config('manage.manage_name').'/'.config('manage.version').'/System/shippingTemplateSave')}";
          data.area_code = data.select;
        delete data['select'];
      https(url, data, 'post', 1, '正在保存信息').then(res => {
        xkMsg(res.result_msg);
      }, fail => {})
      return false;
    });
  });
</script>
{/block}
